package com.cityp.service.impl;

import com.cityp.bean.tool;
import com.cityp.mapper.toolMapper;
import com.cityp.service.toolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class toolServiceImpl implements toolService {
    @Autowired
    private toolMapper toolMapper;

    @Override
    public List<tool> viewAll() {
        return toolMapper.viewAll();
    }

    @Override
    public int addOne(tool tool) {
        return toolMapper.addOne(tool);
    }

    @Override
    public int delOne(int id) {
        return toolMapper.delOne(id);
    }

    @Override
    public int changeOne(int id, int type, String para) {
//        return switch (type){
//            case 1 -> toolMapper.changeType(para,id);
//            case 2 -> toolMapper.changeUse(para,id);
//            case 3 -> toolMapper.changeSwitch(id);
//            case 4 -> toolMapper.changeName(para,id);
//            default -> 0;
        if (type == 1) {
            return toolMapper.changeType(para, id);
        } else if (type == 2) {
            return toolMapper.changeUse(para, id);
        } else if (type == 3) {
            return toolMapper.changeSwitch(id);
        } else if (type == 4) {
            return toolMapper.changeName(para, id);
        }
        return 0;
    }
}